<template>
	<view>
		<view style="text-align: center;font-size: 30rpx;padding: 20rpx;color: #FFFFFF;">登录</view>
		<view class="titleBox">
			<view style="display: flex;">
				<view style="width: 25%;">
					<image src="../../static/icon/logo.png" style="width: 150rpx;height: 150rpx;border-radius: 50%;">
					</image>
				</view>
				<view style="margin-top: 5%;">
					<view class="title">欢迎您使用习水养殖产业平台！</view>
					<!-- <view class="title">共管系统</view> -->
					<view class="title">酒水行业领先的供应链金融服务平台</view>
				</view>
			</view>
		</view>
		<view class="inputBox">
			<view class="input_border">
				<uni-easyinput :styles="styles" :placeholderStyle="placeholderStyle" v-model="paramForm.openUser" focus
					placeholder="第三方公司ID:" @input="input"></uni-easyinput>
			</view>
			<view class="input_border">
				<uni-easyinput :styles="styles" :placeholderStyle="placeholderStyle" type="password"
					v-model="paramForm.openId" placeholder="第三方操作员ID:"></uni-easyinput>
			</view>
			<view class="input_border">
				<uni-easyinput :styles="styles" :placeholderStyle="placeholderStyle" v-model="paramForm.clientType"
					focus placeholder="客户端类型:" @input="input"></uni-easyinput>
			</view>
			<view class="input_border">
				<uni-easyinput :styles="styles" :placeholderStyle="placeholderStyle" type="password"
					v-model="paramForm.outCustNo" placeholder="渠道ID:"></uni-easyinput>
			</view>
			<view class="input_border">
				<uni-easyinput :styles="styles" :placeholderStyle="placeholderStyle" v-model="paramForm.backUrl" focus
					placeholder="渠道ID:" @input="input"></uni-easyinput>
			</view>
			<view v-html="contents">
			</view>
			<!-- <evan-checkbox-group style="display: flex;margin-top: 50rpx;">
				<evan-checkbox v-model="check" key="1" label="1"></evan-checkbox>
				<view style="margin-left: 10rpx;color: #FFFFFF;display: flex;">已阅读并同意 <view @click="ysxy">《隐私协议》</view>和
					<view @click="fwxy">《用户服务协议》</view>
				</view>
			</evan-checkbox-group> -->
		</view>
		<view class="buttonBox">
			<button class="button_fix" id="sumbitButton" @click="onSubmit" size="default">登录</button>
			<!-- <button class="button_fix" style="margin-top: 20rpx;" @click="wx" size="default">微信登录</button> -->
		</view>
		<uni-popup ref="message" type="message">
			<uni-popup-message :type="msgType" :message="messageText" :duration="1000"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				encrypt: "MIIDTwYJKoZIhvcNAQcDoIIDQDCCAzwCAQAxggGkMIIBoAIBADCBhzBvMR8wHQYDVQQDDBZKUi5KRC5jb20gVGVzdCBVc2VyIENBMSQwIgYDVQQLDBtXYW5nWWluIFNlY3VyaXR5Q2VudGVyIFRlc3QxGTAXBgNVBAoMEFdhbmdZaW4uY29tIFRlc3QxCzAJBgNVBAYTAkNOAhQ1z86brVxemd55iNt9WLMl2qRQpzANBgkqhkiG9w0BAQEFAASCAQChom+VuHYxmi7RKdyu+MWQfiHK7V5vatbfAgB4lwPOhZqRp12iZ9s690YP35MUJcXJte2sUXETvv4i/xHyLbmO/R8RqruAtG8AEEyh+e/uJi2MVVRuYQ45GvvM19wlJ8VdIUxESj58rxrFixm7bolh9J3fzhPlANEPmjbeSvCPISnbI5gv/6upC1JthFkwKL60iDZA9WIvEoro6a7QVIQKCfee29XDEIOnHX0EoXSWpi1HdCFnYnX8CR6qpdiJ3r4PqIAaTMsBysP6H8lfZkmlxUS1MVehyQJgnBBPGaKmpqG3KtYnyA55+8lRym3WjqO6wAgB0ReOIvsNXjsZyr1eMIIBjQYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAgChoNatzTlPICCAWhRUHt7MGqDApuXAVREMjuQntSftWuPuo8OgwADZSOrkwYcoe83SkIVoBNbhipL+JpSALbo+b7a7YCYCULxonD/dHxvWOuVNJX6YLw/G6EUPg/4LW8HfezFq/OI4Qlopvn8KvbS760aXmafdooqKGvN1Mhhr6iff0dsxw2PN7ldAaQ6hVqF0/HEP8ZZik5AhkhhwByEc4UXj3VODmfVc6c86dLsdu6zZ2KkqMhK6CAyyjUc3witYf8pOBAyN9ptnQsCtDlNYamsbVHNgRlrqCc3g9E7fP2vVorr3keNSJx9SyHYoSXg8V9UE3f2AMx8CrgpgxiSE3o/+dyJfshRuSrtIjNEfZQkwhLcqaVwfepY6S5hvZJHS3cJsjEYKeig0TDkmy1dVOCjO3O8g1Q+vOVWt6H5iejMBzs5rmg9C2a7dR4mEVvd6Gdoez843Y3Fzw6nwQQ4zejnUxl+ddKYQXFfC8Pi/26rIvE=",
				gwSign: "Utmmr01akG3MPgU79/IrWb+6eDTJx8gLUSCtfeaNrlRB6MTPeL+ifojC/mlXA3gdk8ifrXGs/dM8mp3z7QV968y1NbKiTT1SJXJhiJBdmbSTdK40RImAaQsryRL0A9xplWbVi7HSkqcowC+wIEkEEDAL7WKqsENY6k5rJodPl20=",
				jrgwRequestTime: "1692685652550",
				jrgwEnterpriseUserId: "A2021122104140",
				contents: '',
				content: `
								<form id="scenceForm" action="https://phevos.jddglobal.com/shapi/v1/user/register" method="post">
									<input type="hidden" name="jrgw-user-id-type" value="jrgwUserIdType" />
									<input type="hidden" name="gw-encrypt-type" value="gwEncryptType" />
									<input type="hidden" name="gw-sign-type" value="gwSignType" />
									<input type="hidden" name="encrypt" id="encrypt" value="encrypt" />
									<input type="hidden" name="gw-sign" id="gw-sign" value="gwSign" />
									<input type="hidden" name="jrgw-request-time" id="jrgw-request-time" value="jrgwRequestTime" />
									<input type="hidden" name="jrgw-enterprise-user-id" id="jrgw-enterprise-user-id" value="jrgwEnterpriseUserId" />
									<input type="submit" />
								</form>
								`,
				placeholderStyle: "font-size:28rpx;color:#FFFFFF",
				styles: {
					color: '#FFFFFF',
					borderColor: 'transparent',
					backgroundColor: '#f5f5f5',
					size: '30rpx'
				},
				type: 2000,
				code: '',
				email: '',
				password: '',
				msgType: 'success',
				messageText: '这是一条成功提示',
				check: false,
				paramForm: {
					openUser: '952268671',
					openId: '952268671',
					clientType: 'H5',
					outCustNo: '25163',
					backUrl: 'https://loan.jd.com/cgrz/portal?productCode=25163'
				},
				jdLoginFrom: {
					// jrgwUserIdType: '',
					// gwEncryptType: '',
					// gwSignType: '',
					// encrypt: '',
					// gwSign: '',
					// jrgwRequestTime: '',
					// jrgwEnterpriseUserId: ''
				}
			};
		},
		//第一次加载
		onLoad(e) {
			this.onSubmit();
			// if(e.type == 'productApply'){
			// 	this.onSubmit();
			// }
			// else{
			// 	this.onSubmitFinancing(e.salesOrderId)
			// 	console.log(e.type+'###')
			// }
		},


		methods: {
			submitForm() {
				const form = this.$refs.sceneForm;
				form.submit(); // 提交表单
			},
			ysxy() {
				uni.navigateTo({
					url: '/pages/login/ysxy'
				})
			},
			fwxy() {
				uni.navigateTo({
					url: '/pages/login/fwxy'
				})
			},

			messageToggle(type, msg) {
				this.msgType = type
				this.messageText = msg
				this.$refs.message.open();
			},
			onSubmitFinancing(e) {
				//融资联合登录
				let opt = {
					url: 'finance/jd/getJdLoginParams/payUrl/'+uni.getStorageSync('userInfo').customerId + '/' + e,
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					this.jdLoginFrom = res.data.data
					console.log(this.jdLoginFrom)
					this.contents = `
								<form id="scenceForm" action="https://phevos.jddglobal.com/shapi/v1/user/register" method="post">
									<input type="hidden" name="jrgw-user-id-type" value="0" />
									<input type="hidden" name="gw-encrypt-type" value="${this.jdLoginFrom.gwEncryptType}" />
									<input type="hidden" name="gw-sign-type" value="${this.jdLoginFrom.gwSignType}" />
									<input type="hidden" name="encrypt" id="encrypt" value="${this.jdLoginFrom.encrypt}" />
									<input type="hidden" name="gw-sign" id="gw-sign" value="${this.jdLoginFrom.gwSign}" />
									<input type="hidden" name="jrgw-request-time" id="jrgw-request-time" value="${this.jdLoginFrom.jrgwRequestTime}" />
									<input type="hidden" name="jrgw-enterprise-user-id" id="jrgw-enterprise-user-id" value="${this.jdLoginFrom.jrgwEnterpriseUserId}" />
									<input style="display:none;" class="jdLogin" type="submit"/>
								</form>
								`
					setTimeout(() => {
						var form = document.getElementById('scenceForm');
						console.log(form)
						if (form) {
							form.submit();
							console.log('点击成功')
						} else {
							console.log('表单元素未找到');
						}
					}, 100)
			
				})
			},
			onSubmit() {
				//开通产品联合登录
				let opt = {
					url: 'finance/jd/getJdLoginParams/productUrl/'+uni.getStorageSync('userInfo').customerId,
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, this.paramForm).then(res => {
					this.jdLoginFrom = res.data.data
					console.log(this.jdLoginFrom)
					this.contents = `
								<form id="scenceForm" action="https://phevos.jddglobal.com/shapi/v1/user/register" method="post">
									<input type="hidden" name="jrgw-user-id-type" value="0" />
									<input type="hidden" name="gw-encrypt-type" value="${this.jdLoginFrom.gwEncryptType}" />
									<input type="hidden" name="gw-sign-type" value="${this.jdLoginFrom.gwSignType}" />
									<input type="hidden" name="encrypt" id="encrypt" value="${this.jdLoginFrom.encrypt}" />
									<input type="hidden" name="gw-sign" id="gw-sign" value="${this.jdLoginFrom.gwSign}" />
									<input type="hidden" name="jrgw-request-time" id="jrgw-request-time" value="${this.jdLoginFrom.jrgwRequestTime}" />
									<input type="hidden" name="jrgw-enterprise-user-id" id="jrgw-enterprise-user-id" value="${this.jdLoginFrom.jrgwEnterpriseUserId}" />
									<input style="display:none;" class="jdLogin" type="submit"/>
								</form>
								`
					console.log(this.contents)
					setTimeout(() => {
						var form = document.getElementById('scenceForm');
						console.log(form)
						if (form) {
							form.submit();
							console.log('点击成功')
						} else {
							console.log('表单元素未找到');
						}
					}, 100)

				})
			}
		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background: linear-gradient(to right, #00c6fb 0%, #005bea 100%);
		/* background: url(../../static/img/backgroundImg.png)	no-repeat center center fixed; */
		background-size: cover;
		box-sizing: border-box;
	}

	.titleBox {
		width: 91%;
		margin: 0 auto;
		margin-top: 5%;
		/* text-align: center; */
	}

	.title {
		font-size: 28rpx;
		font-weight: bold;
		padding: 10rpx;
		color: #F1F1F1;
		letter-spacing: 5rpx;
	}

	.inputBox {
		width: 85%;
		margin: 0 auto;
		margin-top: 10%;

	}

	.input_border {
		width: 100%;
		border-bottom: 2px solid #007AFF;
		margin-top: 30rpx;
	}

	.register {
		float: right;
		color: #F1F1F1;
		font-size: 28rpx;
		margin-top: 20rpx;
		font-weight: bold;
		letter-spacing: 5rpx;
	}

	.buttonBox {
		margin: 0 auto;
		margin-top: 30%;
	}

	.button_fix {
		width: 85%;
		height: 80rpx;
		margin: 0 auto;
		border-radius: 25px;
		color: #2749C8;
		background: #FFFFFF;
		font-weight: bold;
		letter-spacing: 5rpx;
		opacity: 0.9;
		font-size: 28rpx;
		line-height: 80rpx;
	}
</style>